Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/react-reconciler

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-reconciler

TypeScript definitions for react-reconciler

  • 0.28.8
  • ts4.5
  • ts4.6
  • ts4.7
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • ts5.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
921K
decreased by-20.65%
Maintainers
1
Weekly downloads
 
Created

What is @types/react-reconciler?

@types/react-reconciler provides TypeScript definitions for the react-reconciler package, which is a low-level API for creating custom renderers in React. This package allows developers to build custom renderers that can manage how React components are rendered and updated in different environments.

What are @types/react-reconciler's main functionalities?

Creating a Custom Renderer

This code demonstrates how to create a custom renderer using the react-reconciler package. The hostConfig object defines how the renderer should handle various operations like creating instances, appending children, and committing updates.

const Reconciler = require('react-reconciler');
const hostConfig = {
  now: Date.now,
  getRootHostContext: () => ({}),
  getChildHostContext: () => ({}),
  prepareForCommit: () => {},
  resetAfterCommit: () => {},
  createInstance: (type, props) => ({ type, props }),
  appendInitialChild: (parent, child) => { parent.children = parent.children || []; parent.children.push(child); },
  finalizeInitialChildren: () => {},
  prepareUpdate: () => true,
  shouldSetTextContent: () => false,
  createTextInstance: text => text,
  commitUpdate: (instance, updatePayload, type, oldProps, newProps) => { instance.props = newProps; },
  commitTextUpdate: (textInstance, oldText, newText) => { textInstance = newText; },
  removeChild: (parentInstance, child) => { parentInstance.children = parentInstance.children.filter(c => c !== child); }
};
const MyRenderer = Reconciler(hostConfig);
const container = MyRenderer.createContainer({}, false, false);
MyRenderer.updateContainer(<div>Hello, world!</div>, container, null, () => {});

Updating a Custom Renderer

This code demonstrates how to update the custom renderer created in the previous example. The update function changes the content of the container to a new React element.

const update = () => {
  MyRenderer.updateContainer(<div>Hello, React!</div>, container, null, () => {});
};
update();

Other packages similar to @types/react-reconciler

FAQs

Package last updated on 07 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc